<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>活动倒计时</title>
</head>
<body>
    <div id="outer">

    </div>
    <script>
        let seckill_date = new Date("2022-08-25 12:00:00");
        function test(){
            //当前系统
            let now = new Date();

            //1. 相差秒
            let s = (seckill_date-now)/1000;

            if(s<=0){
                clearInterval(dt);
            }

            //获取天数
            let day = parseInt(s / 60 / 60 / 24);
            //获取小时
            let hour = parseInt(s / 60 / 60 % 24);
            //获取分钟
            let minuts = parseInt(s / 60 % 60);
            //获取秒
            let sec = parseInt(s % 60);

            document.getElementById("outer").innerHTML=`活动剩余${day}天${hour}时${minuts}分${sec}秒`;

        }
        let dt = setInterval(test,1000);
    </script>
</body>
</html>